﻿using Sidvall.Net.Mime;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace Sidvall.Net
{
    public static class HttpClientExtension
    {
        #region Public Members

        #region DeleteAsync

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> DeleteAsync(this IHttpClient client, string requestUri)
        {
            return await DeleteAsync(client, requestUri, CancellationToken.None).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> DeleteAsync(this IHttpClient client, string requestUri, CancellationToken cancellationToken)
        {
            return await client.DeleteAsync(new System.Uri(requestUri, System.UriKind.RelativeOrAbsolute), cancellationToken).ConfigureAwait(false);
        }

        #endregion
        #region GetAsync

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> GetAsync(this IHttpClient client, string requestUri)
        {
            return await GetAsync(client, requestUri, HttpCompletionOption.ResponseContentRead, CancellationToken.None).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> GetAsync(this IHttpClient client, string requestUri, HttpCompletionOption completionOption, CancellationToken cancellationToken)
        {
            return await client.GetAsync(new System.Uri(requestUri, System.UriKind.RelativeOrAbsolute), completionOption, cancellationToken).ConfigureAwait(false);
        }

        #endregion
        #region PostAsync

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PostAsync(this IHttpClient client, string requestUri, string json)
        {
            return await PostAsync(client, requestUri, json, CancellationToken.None).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PostAsync(this IHttpClient client, string requestUri, string json, CancellationToken cancellationToken)
        {
            return await client.PostAsync(new System.Uri(requestUri, System.UriKind.RelativeOrAbsolute), json, cancellationToken).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PostAsync(this IHttpClient client, string requestUri, string content, MediaType mediaType)
        {
            return await PostAsync(client, requestUri, content, mediaType, CancellationToken.None).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PostAsync(this IHttpClient client, string requestUri, string content, MediaType mediaType, CancellationToken cancellationToken)
        {
            return await client.PostAsync(new System.Uri(requestUri, System.UriKind.RelativeOrAbsolute), content, mediaType, cancellationToken).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PostAsync(this IHttpClient client, string requestUri, Dictionary<string, string> form)
        {
            return await PostAsync(client, requestUri, form, CancellationToken.None).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PostAsync(this IHttpClient client, string requestUri, Dictionary<string, string> form, CancellationToken cancellationToken)
        {
            return await client.PostAsync(new System.Uri(requestUri, System.UriKind.RelativeOrAbsolute), form, cancellationToken).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PostAsync(this IHttpClient client, string requestUri, System.IO.Stream content, int bufferSize)
        {
            return await PostAsync(client, requestUri, content, bufferSize, CancellationToken.None).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PostAsync(this IHttpClient client, string requestUri, System.IO.Stream content, int bufferSize, CancellationToken cancellationToken)
        {
            return await client.PostAsync(new System.Uri(requestUri, System.UriKind.RelativeOrAbsolute), content, bufferSize, cancellationToken).ConfigureAwait(false);
        }

        #endregion
        #region PutAsync

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PutAsync(this IHttpClient client, string requestUri, string json)
        {
            return await PutAsync(client, requestUri, json, CancellationToken.None).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PutAsync(this IHttpClient client, string requestUri, string json, CancellationToken cancellationToken)
        {
            return await client.PutAsync(new System.Uri(requestUri, System.UriKind.RelativeOrAbsolute), json, cancellationToken).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PutAsync(this IHttpClient client, string requestUri, string content, MediaType mediaType)
        {
            return await PutAsync(client, requestUri, content, mediaType, CancellationToken.None).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PutAsync(this IHttpClient client, string requestUri, string content, MediaType mediaType, CancellationToken cancellationToken)
        {
            return await client.PutAsync(new System.Uri(requestUri, System.UriKind.RelativeOrAbsolute), content, mediaType, cancellationToken).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PutAsync(this IHttpClient client, string requestUri, Dictionary<string, string> form)
        {
            return await PutAsync(client, requestUri, form, CancellationToken.None).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PutAsync(this IHttpClient client, string requestUri, Dictionary<string, string> form, CancellationToken cancellationToken)
        {
            return await client.PutAsync(new System.Uri(requestUri, System.UriKind.RelativeOrAbsolute), form, cancellationToken).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PutAsync(this IHttpClient client, string requestUri, System.IO.Stream content, int bufferSize)
        {
            return await PutAsync(client, requestUri, content, bufferSize, CancellationToken.None).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> PutAsync(this IHttpClient client, string requestUri, System.IO.Stream content, int bufferSize, CancellationToken cancellationToken)
        {
            return await client.PutAsync(new System.Uri(requestUri, System.UriKind.RelativeOrAbsolute), content, bufferSize, cancellationToken).ConfigureAwait(false);
        }

        #endregion
        #region SendAsync

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> SendAsync(this IHttpClient client, string requestUri, HttpMethod method)
        {
            return await SendAsync(client, requestUri, method, CancellationToken.None).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> SendAsync(this IHttpClient client, string requestUri, HttpMethod method, CancellationToken cancellationToken)
        {
            return await client.SendAsync(new System.Uri(requestUri, System.UriKind.RelativeOrAbsolute), method, HttpCompletionOption.ResponseContentRead, cancellationToken).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> SendAsync(this IHttpClient client, string requestUri, HttpMethod method, string json)
        {
            return await SendAsync(client, requestUri, method, json, CancellationToken.None).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> SendAsync(this IHttpClient client, string requestUri, HttpMethod method, string json, CancellationToken cancellationToken)
        {
            return await client.SendAsync(new System.Uri(requestUri, System.UriKind.RelativeOrAbsolute), method, json, HttpCompletionOption.ResponseContentRead, cancellationToken).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> SendAsync(this IHttpClient client, string requestUri, HttpMethod method, string content, MediaType mediaType)
        {
            return await SendAsync(client, requestUri, method, content, mediaType, CancellationToken.None).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> SendAsync(this IHttpClient client, string requestUri, HttpMethod method, string content, MediaType mediaType, CancellationToken cancellationToken)
        {
            return await client.SendAsync(new System.Uri(requestUri, System.UriKind.RelativeOrAbsolute), method, content, mediaType, HttpCompletionOption.ResponseContentRead, cancellationToken).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> SendAsync(this IHttpClient client, string requestUri, HttpMethod method, Dictionary<string, string> form)
        {
            return await SendAsync(client, requestUri, method, form, CancellationToken.None).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> SendAsync(this IHttpClient client, string requestUri, HttpMethod method, Dictionary<string, string> form, CancellationToken cancellationToken)
        {
            return await client.SendAsync(new System.Uri(requestUri, System.UriKind.RelativeOrAbsolute), method, form, HttpCompletionOption.ResponseContentRead, cancellationToken).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> SendAsync(this IHttpClient client, string requestUri, HttpMethod method, System.IO.Stream content, int bufferSize)
        {
            return await SendAsync(client, requestUri, method, content, bufferSize, CancellationToken.None).ConfigureAwait(false);
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#")]
        public static async Task<HttpResponse> SendAsync(this IHttpClient client, string requestUri, HttpMethod method, System.IO.Stream content, int bufferSize, CancellationToken cancellationToken)
        {
            return await client.SendAsync(new System.Uri(requestUri, System.UriKind.RelativeOrAbsolute), method, content, bufferSize, HttpCompletionOption.ResponseContentRead, cancellationToken).ConfigureAwait(false);
        }

        #endregion

        #endregion
    }
}
